/*
 * @Description:
 * @Version: 1.0
 * @Autor: haozhuang
 * @Date: 2020-05-07 15:56:52
 * @LastEditors: haozhuang
 * @LastEditTime: 2020-05-07 17:32:56
 */
import request from '../utils/request'
const projectid = sessionStorage.projectId
const projectId = sessionStorage.projectId
export function getRoleList() {
  return request({
    url: '/role/get',
    method: 'get',
    params: {
      projectid
    }
  })
}

export function roleUpdate(name, ename, id) {
  return request({
    url: '/role/update',
    method: 'post',
    data: {
      name,
      ename,
      id
    }
  })
}

export function roledelete(id) {
  return request({
    url: '/role/delete/' + id,
    method: 'get'
  })
}

export function roleAdd(name, ename,) {
  return request({
    url: '/role/add',
    method: 'post',
    data: {
      name,
      ename,
      projectId
    }
  })
}

export function getAuthorizationList(roleId) {
  return request({
    url: '/role/get/folder/tree/' + roleId,
    method: 'get'
  })
}

export function roleUpdateFolder(roleId, folderId, type, value) {
  return request({
    url: '/role/update/folder',
    method: 'post',
    data: {
      roleId, folderId, type, value
    }
  })
}

export function getUserListByTean(teamID, key) {
  return request({
    url: '/user/findByTeam',
    method: 'get',
    params: {
      teamID, key
    }
  })
}

export function getUserListByProject() {
  return request({
    url: '/user/get',
    method: 'get',
    params: {
      projectId
    }
  })
}

export function userUpdateRole(userId, roleIds) {
  return request({
    url: '/user/update/role/' + userId,
    method: 'post',
    qs: true,
    data: {
      projectId, roleIds
    }
  })
}

export function userDelete(id) {
  return request({
    url: '/user/delete/' + id,
    method: 'get'
  })
}

export function userAdd(userName, realName, sex, phone, qq, email, deptName, userId) {
  return request({
    url: '/user/add',
    method: 'post',
    data: {
      userName, realName, sex, phone, qq, email, deptName, userId, projectId
    }
  })
}
